package com.zhida.smartcontrol.dialog.deldevicedialog;

import android.os.Bundle;
import android.view.View;

import com.zhida.smartcontrol.R;
import com.zhida.smartcontrol.mvp.MVPBaseDialogFragment;

import butterknife.OnClick;

/**
 * author: tanjianpei
 * date: 2019/12/16 016 16:51
 * description: 删除设备确认
 */
public class DelDeviceDIalogFragment extends MVPBaseDialogFragment<DelDeviceDIalogContract.View, DelDeviceDIalogPresenter> implements DelDeviceDIalogContract.View {
    public static DelDeviceDIalogFragment newInstance(String id) {
        Bundle args = new Bundle();
        args.putString("id", id);
        DelDeviceDIalogFragment fragment = new DelDeviceDIalogFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected Object getLayout() {
        return R.layout.dialog_del_device;
    }

    @Override
    protected void initDatas(Bundle savedInstanceState) {

    }

    @OnClick({R.id.btn_confirm, R.id.btn_cancel})
    public void click(View v) {
        switch (v.getId()) {
            case R.id.btn_confirm:
                String id = getArguments().getString("id");
                mPresenter.requestDelete(id);
                break;
            case R.id.btn_cancel:
                dismiss();
                break;
        }
    }

    @Override
    public void onSuccess() {
        if (null != mListener) {
            mListener.onDestroy(null, true);
        }
        dismiss();
    }

}
